﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ARA.Domain.Services
{
    public class AddRecordService : IDisposable
    {
        private ARADbContext _dbContext;

        public AddRecordService()
        {
            _dbContext = new ARADbContext();
        }

        public void Add(Entities.Record record)
        {
            _dbContext.Set<Entities.Record>().Add(record);
        }

        public bool Commit()
        {
            try
            {
                _dbContext.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        public void Dispose()
        {
            if (_dbContext != null)
            {
                try
                {
                    _dbContext.Dispose();
                }
                catch(Exception ex)
                {

                }
            }
        }
    }
}
